<template>
  <div class="WorkingSchedule" v-loading="loading">
    <el-form ref="form" :model="form" label-position="top" class="myform">
      <div>
        <el-form-item label="工厂名:" class="myform-item">
          <el-input
            v-model="form.factory_name"
            placeholder="请输入工厂名"
            @keyup.enter.native="onSearch"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="款号:" class="myform-item">
          <el-input
            v-model="form.type_no"
            placeholder="请输入款号"
            @keyup.enter.native="onSearch"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="加工单:" class="myform-item">
          <el-input
            v-model="form.processing_code"
            placeholder="请输入加工单"
            @keyup.enter.native="onSearch"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="确认状态:" class="myform-item">
          <el-select v-model="form.status" placeholder="请选择" clearable>
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </div>
      <div>
        <el-form-item style="margin-top: 50px">
          <el-button type="primary" @click="onSearch">查询</el-button>
        </el-form-item>
      </div>
    </el-form>
    <el-table
      :data="tableData"
      style="width: 100%"
      border
    >
      <el-table-column
        label="工厂名"
        align="center"
        prop="factory_name"
      >
      </el-table-column>
      <el-table-column label="生产加工单" align="center" prop="processing_code">
      </el-table-column>
      <el-table-column label="款号" align="center" prop="type_no">
      </el-table-column>
      <el-table-column label="数量" align="center" prop="num">
      </el-table-column>
      <el-table-column label="理单员" align="center" prop="order_processor">
      </el-table-column>
      <el-table-column label="QC质检员" align="center" prop="qc_user">
      </el-table-column>
      <el-table-column label="产品问题" align="center" prop="reason_title">
      </el-table-column>
      <el-table-column label="图片" align="center" prop="img" width="150">
          <template slot-scope="{ row }">
              <el-image :src="row.img" fit="fill" :lazy="true" :preview-src-list="[row.img]"></el-image>
              
          </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remarks">
      </el-table-column>
      <el-table-column label="提交日期" align="center" prop="createtime">
      </el-table-column>
      <el-table-column label="处理完成日" align="center" prop="chu_time">
          <template slot-scope="{ row }">
              {{row.chu_time?row.chu_time:''}}
          </template>
      </el-table-column>
      <el-table-column label="确认完成日" align="center" prop="finish_time">
          <template slot-scope="{ row }">
              {{row.finish_time?row.finish_time:''}}
          </template>
      </el-table-column>
    </el-table>
    <pagination
      :form="form"
      :total="total"
      @paginationPostOrderTaskList="postAdminApiCodeGetWarningNoticeList"
    />
  </div>
</template>

<script>
import { postAdminApiCodeGetWarningNoticeList } from "@/api";
import pagination from "@/components/pagination.vue";
export default {
  components: { pagination },
  data() {
    return {
      loading: false,
      options: [
        {
          value: 0,
          label: "未处理",
        },
        {
          value: 1,
          label: "处理中",
        },
        {
          value: 2,
          label: "处理完成",
        },
      ],
      form: {
        factory_name: "",
        sku_code: "",
        processing_code: "",
        m_status: "",
        page: 1,
        size: 10,
      },
      tableData: [],
      total: 1,
    };
  },
  activated() {
    let form = this.form;
    this.postAdminApiCodeGetWarningNoticeList(form);
  },
  methods: {
    // 采购列表
    async postAdminApiCodeGetWarningNoticeList(data) {
      this.loading = true;
      this.form = data;
      postAdminApiCodeGetWarningNoticeList(data)
        .then((res) => {
          this.loading = false;
          console.log("采购列表", res);
          this.tableData = res.data;
          this.total = Number(res.total);
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    // 搜索
    onSearch() {
      this.form.page = 1;
      this.form.size = 10;
      this.postAdminApiCodeGetWarningNoticeList(this.form);
    },
  },
};
</script>

<style lang="scss" scoped>
.myform {
  display: flex;
  justify-content: space-between;
  > div {
    display: flex;
  }
  &-item {
    margin-right: 10px;
  }
}
.WorkingSchedule {
  background: #ffff;
  padding: 20px;
  border-radius: 2px;
  @include boxShadow;
}
</style>
